<?php

session_start();
//var_dump($_SESSION);
//echo count($_SESSION);
if(!isset($_SESSION['loggedIn'])){
	header('location:viewAuthadmin.php');
}

include '../config/db_config.php';
include '../lib/kelola_kategori.php';

$kelolaKategori = new kelola_kategori();
$res=$kelolaKategori->select_all_kategori();

$kategori;
while ($row = mysql_fetch_assoc($res)) {
	$p=array();
	$p['NAMA_KATEGORI'] = $row['NAMA_KATEGORI'];
	$p['ID_KATEGORI'] = $row['ID_KATEGORI'];
	$kategori[]=$p;			
}

?>


<html>
	<head>
		<title>Smart Commerce</title>
		<link href="../css/bootstrap.min.css" rel="stylesheet">
		<style type="text/css">
			body {
				padding-top: 60px;
				padding-bottom: 40px;
			}
		</style>
		<link href="../css/bootstrap-responsive.min.css" rel="stylesheet">
	</head>
	<body>
		<div class="navbar navbar-inverse navbar-fixed-top">
			<div class="navbar-inner">
				<div class="container">
				<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
				</a>
				<a class="brand" href="homeAdmin.php">Beranda</a>
				<a class="brand" href="viewKelolaTechno.php">Kelola Akun Technopreneur</a>
				<a class="brand" href="viewKelolaKategori.php">Kelola Kategori Produk</a>
					<div class="nav-collapse collapse">
					<a href='logoutAdmin.php' class="btn pull-right" >Logout</a>
					</div>
				</div>
			</div>
		</div>
		
		<div class="container">
			<div class="hero-unit"style="background-image:url('../images/header.jpg');" >
				<h1>Smart Commerce</h1>
				<blockquote class="pull-right"> 
					<p>Halaman Administrator</p>
				</blockquote>
			</div>
			<ul class="breadcrumb">
				<li><a href="homeAdmin.php">Beranda</a> <span class="divider">/</span></li>
				<li class="active">Kelola Kategori</li>
			</ul>
			
			<?php
				if (!empty($_GET['message']) && $_GET['message'] == 'success') {
				echo '<div class="alert alert-success">Selamat, Anda berhasil menambahkan kategori !<button class="close" data-dismiss="alert">&times;</button></div>';
				}
			?>	
			
			<div class="control-group">
				<h3><strong>Menambahkan Kategori</strong></h3>
				<label class="control-label" for="inputUser">Nama Kategori</label>
					<div class="controls">
					<form class="form-inline" action="tambahKategori.php" method="post">
					<input style="width:270px; height:30px" type="text" id="inputKat" maxlength='25' name="kategori" placeholder="Masukkan nama kategori ..." required="required">
					</div>
					<input type="submit" class="btn btn-small btn-info" value="Tambahkan">
					</form>
			</div>
			
			<h3>Daftar Nama Kategori</h3>
			<table class='table table-bordered table-hover' style='width:850;' border='0' cellspacing='0' cellpadding='2'>
			
			<?php
			if (isset($kategori)&& count($kategori)>0){
			for ($i=0 ; $i<count($kategori); $i++){
			echo '<tr>';
			echo '<td>';
			//echo '<div class="row">';
				echo '<a href="profil_technopreneur.php?id='.$kategori[$i]['ID_KATEGORI'].'" class="pull-left">';
				echo '<div class="span2">';
				echo '<div class="span1"></div>';
				echo '<div class="span7" style="vertical-align:top; color:black; ">';
				echo '<h4>'.$kategori[$i]['NAMA_KATEGORI'].'</h4>';
				echo '</div>';
				echo '</a>';
				echo
				'<form class="form-inline" action="editKategori.php?kategori='.$kategori[$i]['ID_KATEGORI'].'" method="post">
					<input style="width:270px; height:30px" type="text" id="inputKat" maxlength="25" name="kategori" placeholder="Ubah Nama Kategori ..." required="required">
					</div>
					<input type="submit" class="btn btn-small btn-warning" value="Edit">
				</form>';
				
			// echo '</div>';
			echo '</td>';
			echo '</tr>';
			}
			}
			
			else {
			echo '<h5>Technopreneur tidak dapat ditemukan</h5>';
			}
			?>
			
		</div>
			

			
	
</html>